package com.example.SpringBoot_demo.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.example.SpringBoot_demo.bean.Log;
import com.example.SpringBoot_demo.service.ILogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Controller
@RequestMapping()
public class LogController {


        @Autowired(required = false)
        private ILogService ILogService;

        @RequestMapping("viewLog")
        public String getLog(Model model, @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum){
            PageHelper.startPage(pageNum,5);
            List<Log> list = ILogService.viewLog();
            PageInfo<Log> pageInfo = new PageInfo<>(list);
            model.addAttribute("pageInfo",pageInfo);
            System.out.println();
            return "viewLog";
        }

}
